import network

class WLAN:
    def __init__(self):
        self.__ssid = 'iKuai2G-cc7b'
        self.__password = '314314314'
        self.__wlan = network.WLAN(network.STA_IF)
        self.is_connected = False

    def connect(self):
        if self.is_connected:
            return

        self.__wlan.active(True)
        if not self.__wlan.isconnected:
            print("wlan: connecting to network...")
        self.__wlan.connect(self.__ssid, self.__password)
        while not self.__wlan.isconnected():
            pass
        print(f"wlan: connect {self.__ssid} success")
        self.is_connected = True


